export function enumToObject<T extends Record<keyof T, string | number>>(
  enumObj: T,
) {
  return Object.keys(enumObj).reduce(
    (res, k) => {
      if (typeof enumObj[k] === 'string') {
        res[enumObj[k]] = k;
      }

      if (typeof enumObj[k] === 'string' || typeof enumObj[k] === 'number') {
        res[k] = enumObj[k];
      }
      return res;
    },
    {} as {
      [key in keyof T]: T[key] extends string | number ? T[key] : never;
    },
  );
}
